//
//  CXBroadcastViewModel.m
//  XiMaFM
//
//  Created by hcios on 2017/9/2.
//  Copyright © 2017年 hcios. All rights reserved.
//

#import "CXBroadcastViewModel.h"
#import "CXHomeHotNetManager.h"
#import "CXBroadcastModel.h"

@implementation CXBroadcastViewModel

//网络加载数据
-(void)getDataCompletionHandle:(void (^)(NSError *))completed {
    self.dataTask = [CXHomeHotNetManager getRankPageCompletionHandle:^(CXBroadcastModel * responseObject, NSError *error) {
        self.model = responseObject;
        completed(error);
    }];
}


//推荐内容
- (NSString *)mainTitleWithSection:(NSInteger)section {
    if (section == 1) {
        return self.model.data.location;
    }else if(section == 2) {
        return @"排行榜";
    }else {
        return nil;
    }
}


//图片
- (NSURL *)coverURLWithSection:(NSInteger)section index:(NSInteger)index {
    
    if (section == 1) {
        NSString * path = nil;
        path = self.model.data.localRadios[index].coverLarge;
        return [NSURL URLWithString:path];
    }else {
        NSString * path = nil;
        path = self.model.data.topRadios[index].coverLarge;
        return [NSURL URLWithString:path];
    }
}

// 标题
- (NSString *)nameWithSection:(NSInteger)section index:(NSInteger)index {
    if (section == 0) {
        return self.model.data.localRadios[index].name;
    }else {
        return self.model.data.topRadios[index].name;
    }
}


//播放人数
-(NSInteger)playCountWithSection:(NSInteger)section index:(NSInteger)index {
    if (section == 1) {
        return self.model.data.localRadios[index].playCount;
    }else if(section == 2) {
        return self.model.data.topRadios[index].playCount;
    }else {
        return 0;
    }
}

// programName
- (NSString *)programNameWithSection:(NSInteger)section index:(NSInteger)index {
    if (section == 1) {
        return self.model.data.localRadios[index].programName;
    }else if(section == 2) {
        return self.model.data.topRadios[index].programName;
    }else {
        return nil;
    }
}


//标题
- (NSString *)nameWithIndex:(NSInteger)index {
    return self.model.data.categories[index].name;
}


-(NSInteger)categoriesCount {
    return self.model.data.categories.count;
}

@end
